/**
 * API路径配置
 * @author Wu.Liang
 * @date 2024-12-21
 */

// 微服务API前缀配置
export const API_PATHS = {
    // 用户服务
    USER: import.meta.env.VUE_APP_USER_API || '/user',

    // 安全服务
    SECURITY: import.meta.env.VUE_APP_SECURITY_API || '/security',

    // 物业服务
    PROPERTY: import.meta.env.VUE_APP_PROPERTY_API || '/property',

    // 停车服务
    PARKING: import.meta.env.VUE_APP_PARKING_API || '/parking',

    // 社区服务
    COMMUNITY: import.meta.env.VUE_APP_COMMUNITY_API || '/community',

    // 紧急求助服务
    EMERGENCY: import.meta.env.VUE_APP_EMERGENCY_API || '/emergency',

    // 区域管理服务
    REGION: import.meta.env.VUE_APP_REGION_API || '/region',

    // 数据分析服务
    DATA: import.meta.env.VUE_APP_DATA_API || '/data',

    // 合作商服务
    COOPERATION: import.meta.env.VUE_APP_COOPERATION_API || '/cooperation',

    // 消息服务
    MESSAGE: import.meta.env.VUE_APP_MESSAGE_API || '/message',

    // 支付服务
    PAYMENT: import.meta.env.VUE_APP_PAYMENT_API || '/payment'
} as const

// 认证相关路径
export const AUTH_PATHS = {
    LOGIN: '/auth/login',
    LOGOUT: '/auth/logout',
    REFRESH: '/auth/refresh',
    CAPTCHA: '/auth/captcha',
    INFO: '/auth/info',
    SMS_CODE: '/auth/sms-code',
    RESET_PASSWORD: '/auth/reset-password',
    PHONE_LOGIN: '/auth/phone-login'
} as const

// 用户相关路径
export const USER_PATHS = {
    PROFILE: '/profile',
    PASSWORD: '/password',
    AVATAR: '/avatar',
    INFO: '/info',
    LIST: '/list',
    BIND_PHONE: '/bind-phone',
    REGISTER: '/register'
} as const

// 完整API路径构建函数
export const buildApiPath = (service: keyof typeof API_PATHS, path: string): string => {
    return `${API_PATHS[service]}${path}`
}

// 用户服务专用路径构建
export const buildUserApiPath = (path: keyof typeof AUTH_PATHS | keyof typeof USER_PATHS | string): string => {
    return buildApiPath('USER', typeof path === 'string' ? path : AUTH_PATHS[path as keyof typeof AUTH_PATHS] || USER_PATHS[path as keyof typeof USER_PATHS])
} 